package org.grayrabbit.cms.entity;

// Generated 2011-5-11 14:11:22 by Hibernate Tools 3.3.0.GA

import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.grayrabbit.cms.security.PermissionChecker;
import org.grayrabbit.cms.security.SecurityUser;
import org.hibernate.annotations.GenericGenerator;


/**
 * CmsAdmin generated by hbm2java
 */
@Entity
@Table(name = "CMS_ADMIN")
public class Admin implements SecurityUser,java.io.Serializable {

	private static final long serialVersionUID = 5510923309436125299L;
	private String adminId;
	private Role role;
	private String loginName;
	private String passwd;
	private String realName;
	private String nickName;
	private Boolean activeStatus;
	private String memo;
	private String email;
	private String mobile;
	private String telephone;
	private String lastSuccessIp;
	private Date lastSuccessTime;
	private String lastFailIp;
	private Date lastFailTime;
	private Integer failNum;
	private Date createTime;
	private String createLoginName;
	private String createRealName;
	private String updateLoginName;
	private String updateRealName;
	private Date updateTime;
	
	private Set<AdminOperRela> adminOperRelas = new HashSet<AdminOperRela>(0);

	public Admin() {
	}

	public Admin(String adminId) {
		this.adminId = adminId;
	}

	@Id
	@Column(name = "ADMIN_ID", unique = true, nullable = false, length = 32)
	@GeneratedValue(generator = "paymentableGenerator")       
	@GenericGenerator(name = "paymentableGenerator", strategy = "uuid") 
	public String getAdminId() {
		return this.adminId;
	}

	public void setAdminId(String adminId) {
		this.adminId = adminId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ROLE_ID")
	public Role getRole() {
		return this.role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	@Column(name = "LOGIN_NAME", length = 32)
	public String getLoginName() {
		return this.loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}

	@Column(name = "PASSWD", length = 32)
	public String getPasswd() {
		return this.passwd;
	}

	public void setPasswd(String passwd) {
		this.passwd = passwd;
	}

	@Column(name = "REAL_NAME", length = 32)
	public String getRealName() {
		return this.realName;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}

	@Column(name = "NICK_NAME", length = 32)
	public String getNickName() {
		return this.nickName;
	}

	public void setNickName(String nickName) {
		this.nickName = nickName;
	}

	@Column(name = "ACTIVE_STATUS", precision = 1, scale = 0)
	public Boolean getActiveStatus() {
		return this.activeStatus;
	}

	public void setActiveStatus(Boolean activeStatus) {
		this.activeStatus = activeStatus;
	}

	@Column(name = "MEMO", length = 256)
	public String getMemo() {
		return this.memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}

	@Column(name = "EMAIL", length = 256)
	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Column(name = "MOBILE", length = 16)
	public String getMobile() {
		return this.mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	@Column(name = "TELEPHONE", length = 16)
	public String getTelephone() {
		return this.telephone;
	}

	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

	@Column(name = "LAST_SUCCESS_IP", length = 64)
	public String getLastSuccessIp() {
		return this.lastSuccessIp;
	}

	public void setLastSuccessIp(String lastSuccessIp) {
		this.lastSuccessIp = lastSuccessIp;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "LAST_SUCCESS_TIME", length = 7)
	public Date getLastSuccessTime() {
		return this.lastSuccessTime;
	}

	public void setLastSuccessTime(Date lastSuccessTime) {
		this.lastSuccessTime = lastSuccessTime;
	}

	@Column(name = "LAST_FAIL_IP", length = 64)
	public String getLastFailIp() {
		return this.lastFailIp;
	}

	public void setLastFailIp(String lastFailIp) {
		this.lastFailIp = lastFailIp;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "LAST_FAIL_TIME", length = 7)
	public Date getLastFailTime() {
		return this.lastFailTime;
	}

	public void setLastFailTime(Date lastFailTime) {
		this.lastFailTime = lastFailTime;
	}

	@Column(name = "FAIL_NUM", precision = 6, scale = 0)
	public Integer getFailNum() {
		return this.failNum;
	}

	public void setFailNum(Integer failNum) {
		this.failNum = failNum;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "CREATE_TIME", length = 7)
	public Date getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(name = "CREATE_LOGIN_NAME", length = 64)
	public String getCreateLoginName() {
		return this.createLoginName;
	}

	public void setCreateLoginName(String createLoginName) {
		this.createLoginName = createLoginName;
	}

	@Column(name = "CREATE_REAL_NAME", length = 64)
	public String getCreateRealName() {
		return this.createRealName;
	}

	public void setCreateRealName(String createRealName) {
		this.createRealName = createRealName;
	}

	@Column(name = "UPDATE_LOGIN_NAME", length = 64)
	public String getUpdateLoginName() {
		return this.updateLoginName;
	}

	public void setUpdateLoginName(String updateLoginName) {
		this.updateLoginName = updateLoginName;
	}

	@Column(name = "UPDATE_REAL_NAME", length = 64)
	public String getUpdateRealName() {
		return this.updateRealName;
	}

	public void setUpdateRealName(String updateRealName) {
		this.updateRealName = updateRealName;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "UPDATE_TIME", length = 7)
	public Date getUpdateTime() {
		return this.updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "admin")
	public Set<AdminOperRela> getAdminOperRelas() {
		return this.adminOperRelas;
	}

	public void setAdminOperRelas(Set<AdminOperRela> adminOperRelas) {
		this.adminOperRelas = adminOperRelas;
	}

	private Collection<String> perssmins;
	
	@Transient
	public Collection<String> getPerssmins() {
		return perssmins;
	}

	public void setPerssmins(Collection<String> perssmins) {
		this.perssmins = perssmins;
	}

	@Transient
	public Object getUser() {
		return this;
	}

	@Transient
	public String getUserType() {
		return PermissionChecker.USER_TYPE_ADMIN;
	}

	@Transient
	public String getUserName() {
		return this.loginName;
	}
	
	
	//下面代码特别用法，表示用户拥有的权限，非持久数据
	private List<Site> authSites;
	@Transient
	public List<Site> getAuthSites() {
		return authSites;
	}

	public void setAuthSites(List<Site> authSites) {
		this.authSites = authSites;
	}
}
